package org.ala.tiktools.rpc.kcp.netty;

import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelConfig;
import io.netty.channel.MessageSizeEstimator;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.WriteBufferWaterMark;

import java.net.StandardSocketOptions;


/**
 * ServerChannel相关配置
 *
 * @author ala
 * @date 2025-04-14 13:07
 */
public interface IKcpServerChannelConfig extends ChannelConfig {
    /**
     * udp receiver buffer size
     */
    int getUdpReceiveBufferSize();
    IKcpServerChannelConfig setUdpReceiveBufferSize(int receiveBufferSize);
    /**
     * udp sender buffer size
     */
    int getUdpSendBufferSize();
    IKcpServerChannelConfig setUdpSendBufferSize(int sendBufferSize);
    /**
     * Gets the {@link StandardSocketOptions#IP_TOS} option.
     */
    int getUdpTrafficClass();
    IKcpServerChannelConfig setUdpTrafficClass(int trafficClass);
    /**
     * 单机是否可重用端口号
     */
    boolean isReuseAddress();
    IKcpServerChannelConfig setReuseAddress(boolean reuseAddress);

    @Override
    @Deprecated
    IKcpServerChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead);
    /**
     *  写操作最大重试次数
     */
    @Override
    IKcpServerChannelConfig setWriteSpinCount(int writeSpinCount);
    /**
     *  链接超时毫秒数
     */
    @Override
    IKcpServerChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis);
    /**
     *  ByteBuf内存分配器
     */
    @Override
    IKcpServerChannelConfig setAllocator(ByteBufAllocator allocator);
    /**
     *  接受消息时候ByteBuf内存分配器
     */
    @Override
    IKcpServerChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator);
    /**
     *  自动读取数据（是否自动触发read事件）
     */
    @Override
    IKcpServerChannelConfig setAutoRead(boolean autoRead);
    /**
     *  写入失败时自动关闭channel
     */
    @Override
    IKcpServerChannelConfig setAutoClose(boolean autoClose);
    /**
     *  消息大小估算器
     */
    @Override
    IKcpServerChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator);
    /**
     *  写缓冲区高低水位
     *  <p> 超过high，写操作停止
     *  <p> 低于low，写操作继续
     */
    @Override
    IKcpServerChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark);
}
